<%--
  Created by IntelliJ IDEA.
  User: 林锴
  Date: 2018/3/19
  Time: 14:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>密码修改页面</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/common.css" media="all">
    <script src="${pageContext.request.contextPath}/static/css/layui/layui.js"></script>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery-1.12.4.js"></script>
</head>
<body>
    <c:choose>
        <c:when test="${stateMsg!=null}">
            ${stateMsg}
        </c:when>
        <c:otherwise>
            <form class="layui-form" action="${pageContext.request.contextPath}/worker/modifyPassword" method="post">
                <div class="info_form_body">
                    <div class="layui-form-item">
                        <label class="layui-form-label">工号:</label>
                        <div class="layui-input-block">
                            <input id="workerId" readonly type="text" name="workerId" value="${worker.workerId}"  lay-verify="required" placeholder="工号" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">旧密码:</label>
                        <div class="layui-input-block">
                            <input id="oldPassword"  type="password" name="oldPassword"  lay-verify="password" placeholder="旧密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">新密码:</label>
                        <div class="layui-input-block">
                            <input id="newPassword"  type="password" name="password"  lay-verify="password" placeholder="新密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">确认密码:</label>
                        <div class="layui-input-block">
                            <input id="newPassword2"  type="password" lay-verify="password" placeholder="确认密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button lay-submit="" lay-filter="check" class="layui-btn">修改信息</button>
                        </div>
                    </div>
                </div>
            </form>
        </c:otherwise>
    </c:choose>

<script>
    layui.use('form',function () {
        var form=layui.form;
        form.verify({
            password:[/(.+){6,12}$/, '密码必须6到12位']
        });

        form.on('submit(check)',function (data) {

            var psw=$('#newPassword').val();
            var psw2=$('#newPassword2').val();

            if(psw!=psw2){
                layer.alert("两次新密码不一致");
                return false;
            }

            return true;
        })
    });
</script>
</body>
</html>
